import javax.microedition.lcdui.Graphics;

public final class ca extends ba
{

    private ba a;
    private boolean b;
    private int c;
    private int d;
    private int e;
    private int f;

    public ca(ba ba1)
    {
        super(bh.a("window"), -100, -100);
        a(0, ba1);
    }

    public final int g_()
    {
        return 1;
    }

    public final ba a(int i)
    {
        return a;
    }

    public final void a(int i, ba ba1)
    {
        if(ba1 != null)
            ba1.H = this;
        a = ba1;
    }

    public final void b(int i, int j)
    {
        b = true;
        c = i;
        d = j;
    }

    private static final int b(int i, int j, int k)
    {
        if(j == 0)
            return 0;
        if(j < 0)
            if(j < -100)
                return i;
            else
                return (-j * i) / 100;
        if(j + k > i)
            return i;
        else
            return j + k;
    }

    private static int c(int i, int j, int k)
    {
        int l;
        if((l = i) + k > j)
            l = j - k;
        if(l < 0)
            l = 0;
        return l;
    }

    public final void b(int i, int j, int k, int l)
    {
        o o1;
        int i1;
        int j1;
        int k1;
        int l1;
        o1 = bh.a("window");
        o o2 = bh.a("widewindow");
        if(super.I == o1 || super.I == o2)
        {
            super.I = ce.a(11) ? o2 : o1;
            if(ce.a(28))
                super.I = o1;
        }
        super.K.b(i, j, k, l);
        if(a == null)
            return;
        i1 = (o1 = super.I).g();
        j1 = o1.h();
        k1 = o1.c;
        l1 = o1.d;
        if(k1 == 0)
            k1 = a.u();
        if(l1 == 0)
        {
            int i2;
            if((i2 = k1) < -100)
                i2 = k;
            else
            if(i2 < 0)
                i2 = (-i2 * k) / 100;
            if((i2 -= i1) < 0)
                i2 = 0;
            l1 = a.j(i2);
        }
        k1 = b(k, k1, i1);
        l1 = b(l, l1, j1);
        boolean flag = false;
        int j2;
        int k2;
        if(b){
        switch(o1.e & 0xd){
            case 1:  // L4
                j2 = c - k1 / 2;
                break;
            case 8:  // L5
                j2 = c - k1;
                break;
            default:
                j2 = c;
                break;
        }
        switch(o1.e & 0x32){
            case 2:
                k2 = d - l1/2;
                break;
            case 32:
                k2 = d - l1;
                break;
            default:
                k2 = d;
                break;
        }
        j2 = c(j2, k, k1);
        k2 = c(k2, l, l1);
        }else{
        j2 = bh.a(o1.e, k, k1);
        k2 = bh.b(o1.e, l, l1);
        }
        a.b(j2 + o1.c(), k2 + o1.e(), k1 - i1, l1 - j1);
        e = j2;
        f = k2;
    }

    public final void a(Graphics g, bh bh1)
    {
        if(a != null)
        {
            g.translate(e, f);
            o o1 = super.I;
            int i = a.x() + o1.g();
            int j = a.y() + o1.h();
            o1.a(this, g, i, j, true);
            bh.a(g, bh1, a);
        }
    }
}